<?php
 if(!isset($sp))	
  	$sp=explode("/",$_SERVER['PHP_SELF']);

  if($_SERVER['HTTP_HOST'] == "localhost" || $_SERVER['HTTP_HOST'] == "192.168.1.34")
   {
	  $sp[1] = '/' . $sp[1];
   }
  else
	  $sp[1] = '';
  
  $w_root = $_SERVER['SERVER_NAME'] . $sp[1];
  $w_root = str_replace('//','/',$w_root);
  $w_root = str_replace('\\\\','\\',$w_root);
  
  $s_root = $_SERVER['DOCUMENT_ROOT'] . $sp[1];
  $s_root = str_replace('//','/',$s_root);
  $s_root = str_replace('\\\\','\\',$s_root); 
/*========End Setting up web root and server root =============*/
  require_once $s_root.'/libraryfiles/config.php'; 
  
	$content = 'edit_seller.php';
	$include='
		<link rel="stylesheet" type="text/css" href="'.W_ROOT.'/css/mStyle.css">
		<script src="'.W_ROOT.'/js/jquery.js" type="text/javascript"></script>
	';

	$start = '<span class="coloRed">*</span>';
	$error = isset($_GET['error'])?$_GET['error']:'';
	
	$editRow="SELECT tbluser.id, tbluser_profile.first_name AS fname, tbluser_profile.last_name AS lname, tbluser.user_pass AS upass, tbluser.email AS uemail, tbluser_profile.phone AS uphone , tbluser_profile.mobile AS umobile, tbluser_profile.address AS uaddress, tbluser.country_id, pharmacy_name, pharmacy_image, tblpharmacy.province_id AS province, tblpharmacy.email AS pemail, tblpharmacy.phone AS pphone, tblpharmacy.address AS paddress, fax, website, license, zip,city,region 
FROM tbluser
INNER JOIN tbluser_profile ON tbluser.id = tbluser_profile.provider
INNER JOIN tblpharmacy ON tblpharmacy.user_id = tbluser.id
WHERE tbluser.id=".$_SESSION['acc_id'];
	$query=mysql_query($editRow);
	
	$result=mysql_fetch_array($query);
	$success = isset($_GET['success'])?$_GET['success']:'';	
	
?>


<?php 
//edit
//	$editRow="SELECT * FROM tbluser INNER JOIN tblcountries ON tbluser.id=tblcountries.id INNER JOIN tbluser_profile ON tbluser_profile.provider=tbluser.id where tbluser.id=".$_SESSION['acc_id'];
//	$query=mysql_query($editRow);
//	
//	$result=mysql_fetch_array($query);
//	//print_r($result);die();
?>
        <div style="margin-right: 15px;">
        
        <div class="block-header">
            <h4><!--Your Account--><?php echo $lang['UR_ACCOUNT']; ?></h4>
        </div>
    <?php
		if($success!=""){
	?>	
		<div align="center"><strong style="color:#F00;"><?php echo $success;?></strong></div>
	<?php
	}
	?>
    	<form name="update" id="registerForm" method="post" enctype="multipart/form-data" action="<?php echo W_ROOT; ?>/process_register.php?action=edit_s">
        <input class="btn right" type="submit" name="edit" id="btnEditSeller" value="<?php echo $lang['AD_EDIT_PROFILE'];?>" onclick="editSeller();" />
        <div class="clear"></div>
        	<table style="width:100%">
            	<!--<tr height="10"><td></td></tr>-->
                <tr>
                	<td colspan="3">
                    	<div style="float:left; width:300px;"><span style="color:#417EFB; font-size:18px;"><!--Personal Information--><?php echo $lang['PERSONALINFORR'];?></span></div>
                    	<div style="float:right;"><span class="coloRed"><!--Note : All (*) are required--><?php echo $lang['NOTESTAR'];?></span></div>
                    </td>
                </tr>
            	<!--<tr>
                	<td width="400"><span style="color:#417EFB; font-size:18px;">Personal Information</span></td>
                    <td></td>
                    <td><span class="coloRed">Note : All (*) are required</span></td>
                </tr>-->
                <tr>
                	<td><!--First Name--><?php echo $lang['SHIP_FIR_NAME'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="first_name" id="first_name" value="<?php echo $result['fname']; ?>" onclick="editSeller();"/></td>
                </tr>
                <tr>
                	<td><!--Last Name--><?php echo $lang['SHIP_LAS_NAME'] ;?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="last_name" id="last_name" value="<?php echo $result['lname']?>" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--Password--><?php echo $lang['LOG_PASSWORD'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="password" class="b" name="us_pass" id="us_pass" value="<?php echo $result['upass']?>" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--Email--><?php echo $lang['SHIP_EMAIL'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="email" id="email" value="<?php echo $result['uemail']?>" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--Telephone--> <?php echo $lang['SHIP_PHONE'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="phone" id="phone" value="<?php echo $result['uphone']?>" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--Mobile--><?php echo $lang['SHIP_MPHONE'] ;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="mobile" id="mobile" value="<?php echo $result['umobile']?>" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--Address, Street--><?php echo $lang['ADDRESSSTREET'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="address" id="address" value="<?php echo $result['uaddress']?>" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--Province / State--><?php echo $lang['SHIP_PRO_STATE'] ;?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input class="b" value="<?php echo $result['region']?>" type="text" name="province" id="txtShippingState" onblur="sh_state()" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--City--><?php echo $lang['SHIP_CITY'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input class="b" value="<?php echo $result['city']?>" type="text" name="city" id="txtShippingCity" onblur="sh_city()" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--Country--><?php echo $lang['SHIP_COUNTRY'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td>
                    	<select id="country" name="country" class="b" onclick="editSeller();">
                        	<?php
								$str = "SELECT id, country_name from tblcountries order by country_name";
								$query = mysql_query($str);
								$num_rows = mysql_num_rows($query);
								while($data = mysql_fetch_array($query)){
							?>
                            <option value="<?php echo $data['id'];?>" <?php echo($data['id']==$result['country_id'])?' selected="selected"':''?>><?php echo $data['country_name']; ?></option>
                            <?php
							}
							?>
                      	</select>
                    </td>
                </tr>
                <tr>
                	<td><!--Postal / Zip Code--><?php echo $lang['SHIP_ZIP_CODE'];?> <?php echo $start;?></td>
                    <td>:</td>
                    <td><input class="b" value="<?php echo $result['zip']?>" type="text" name="zip" id="txtShippingPostalCode" onblur="sh_zip()" onclick="editSeller();" /></td>
                </tr>
                 <tr height="60">
                	<td colspan="3">
                    	<div style="margin-top:30px;"><span style="color:#417EFB; font-size:18px;"><!--Company Infomation--><?php echo $lang['COMPANYINFO'];?></span></div>
                    </td>
                </tr>
                
                <tr>
                	<td><!--Company Name--><?php echo $lang['COMPANYNAMEE'] ;?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="pharmacy_name" id="pharmacy_name" value="<?php echo $result['pharmacy_name']?>" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--Logo--> <?php echo $lang['LOGO'];?></td>
                    <td>:</td>
                    <td>
                    	<!--<form action="#" method="post" enctype="multipart/form-data">
							<input type="file" name="image" id="file" />
							
						</form>-->
                        <input type="file" class="b" name="logo_image" id="file" />                        
                     </td>
                </tr>
                <tr>
                	<td></td>
                    <td></td>
                    <td><?php
						if($result['pharmacy_image']!=""){
						?>	
                        &nbsp;<img src="<?php echo W_ROOT;?>/upload/<?php echo $result['pharmacy_image'];?>" class="border" />
						<?php	
						}
						else{
							echo $lang['NOIMAGESS'];	
						}
						?>
                        
                        </td>
                </tr>
                <tr>
                	<td><!--Address--><?php echo $lang['ADDRSELLER'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="pharmacy_address" id="pharmacy_address" value="<?php echo $result['paddress']; ?>" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--Location--><?php echo $lang['LOCATION'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td>
                    	<select id="location" class="b" name="location" onclick="editSeller();">
                        	<?php
								$query="SELECT * FROM tblprovince";
								
								$data=mysql_query($query);
								while($val=mysql_fetch_assoc($data)){
							?>                            
                                
                                 <option value="<?php echo $val['province_id'];?>" <?php echo($val['province_id']==$result['province'])?' selected="selected"':''?>><?php echo $val['province_name']; ?></option>
                                
                                
                            <?php } ?>
                        </select> 
                    </td>
                </tr>
                 <tr>
                	<td><!--Phone--><?php echo $lang['SHIP_PHONE'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="pharmacy_phone" id="pharmacy_phone" value="<?php echo $result['pphone']; ?>" onclick="editSeller();" /></td>
                </tr>
                 <tr>
                	<td><!--Fax--><?php echo $lang['FAX'];?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="pharmacy_fax" value="<?php echo $result['fax']; ?>" onclick="editSeller();" /></td>
                </tr>
                 <tr>
                	<td><!--Email--><?php echo $lang['SHIP_EMAIL'] ;?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="pharmacy_email" id="pharmacy_email" value="<?php echo $result['pemail']; ?>" onclick="editSeller();" /></td>
                </tr>
                 <tr>
                	<td><!--Website--><?php echo $lang['WEBSITE'];?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="pharmacy_website" value="<?php echo $result['website']; ?>" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td><!--License--><?php echo $lang['LICENSES'];?><?php echo $start;?></td>
                    <td>:</td>
                    <td><input type="text" class="b" name="pharmacy_license" value="<?php echo $result['license']; ?>" onclick="editSeller();" /></td>
                </tr>
                <tr>
                	<td></td>
                    <td></td>
                    <td>
                    	<input type="checkbox" class="b" name="newsletter" value="1" /><!--	Receive newsletter?--><?php echo $lang['RCIEVENEW'];?>
                    </td>
                </tr>
                <tr>
                	<td></td>
                    <td></td>
                    <td>
                    	<input class="btn" type="submit" name="edit" id="btnEditSeller" value="<?php echo $lang['AD_EDIT_PROFILE'];?>" onclick="editSeller();" />
                    </td>
                </tr>
            </table>
        </form>
	</div><!--<div class="box">-->
